<?php

namespace app\admin\controller\pay;

use app\common\controller\Backend;

use think\Controller;
use think\Request;

/**
 * 收费项目信息管理
 *
 * @icon fa fa-circle-o
 */
class Project extends Backend
{

    /**
     * PayProject模型对象
     */
    protected $model = null;
    protected $companyModel = null;
    protected $communityModel = null;
    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('PayProject');
        $this->companyModel = model('Company');
        $this->communityModel = model('Community');
        $this->view->assign('paycompany', $this->companyModel->where('companytype=2')->field('id,companyname')->select());
        $this->view->assign('suppliercompany', $this->companyModel->where('companytype=3')->field('id,companyname')->select());
        $this->view->assign('community', $this->communityModel->where(array('code' => array('in', parent::getCommunityIdByAuth())))->field('id,name')->select());
    }

    /**
     * 默认生成的控制器所继承的父类中有index/add/edit/del/multi五个方法
     * 因此在当前控制器中可不用编写增删改查的代码,如果需要自己控制这部分逻辑
     * 需要将application/admin/library/traits/Backend.php中对应的方法复制到当前控制器,然后进行修改
     */
    public function add()
    {
        return parent::create('form');
    }

    public function edit($ids = NULL)
    {
        return parent::modify($ids, 'form');
    }

    public function del($ids = null)
    {
        $where = array(
            'id' => array('in', $ids)
        );
        parent::delete($where);
    }
}
